/**
 * Copyright (C), 2020, JieYi Software System Co., Ltd.
 * All rights reserved.
 * FileName:       ConsoleCommonService.java
 *
 * @Description:
 * @author: feiwe
 * Modification History:
 * Date         Author        Version        Discription
 * -------------------------------------------------------
 * 2020/11/16      feiwe                         add
 */


package com.fengwei.service;

import com.fengwei.form.MdmsUser;
import com.fengwei.util.PltResult;
import com.fengwei.util.VerifyException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@Service
public class ConsoleCommonService {
    private final static Logger logger = LoggerFactory.getLogger(ConsoleCommonService.class);

    public MdmsUser checkAndGetUser(HttpServletRequest request){
        HttpSession session = request.getSession();
        logger.debug("session.getId():" + session.getId());
        MdmsUser mdmsUser = (MdmsUser) session.getAttribute("mdmsUser");
        if(null==mdmsUser){
            throw new VerifyException(PltResult.RESULT_CF988);
        }
        return mdmsUser;
    }
}
